package com.shark.commons.base.service;

import java.util.List;

import com.shark.commons.base.exception.AppException;
import com.shark.commons.base.web.AjaxResult;
import com.shark.commons.base.web.dto.DataGrid;

/**
 * 通用Service接口
 */
public interface IService<T> {

	int insert(T entity) throws AppException;
	
	int insertSelective(T entity) throws AppException;
	
	int deleteByPrimaryKey(Object id) throws AppException;

    int updateByPrimaryKeySelective(T entity) throws AppException;

    int updateByPrimaryKey(T entity) throws AppException;

    T selectByPrimaryKey(Object id) throws AppException;
    
    List<T> selectAll() throws AppException ;
    
    /**
   	 * 检查字段的值是否已存在
   	 * @param id ID可以为NULL，主要用于update操作
   	 * @param field coulum名
   	 * @param fieldVal column值
   	 * @return
   	 */
   	int existsFileldValue(Object id, String field, String fieldVal) throws AppException ;
   	
    /**
     * 批量删除
     * @param ids 主键
     * @return
     */
    AjaxResult<Object> deleteBatchByKeys(Object[] ids) throws AppException ;
    
    /**
     * 分页查询
     * selectByPage是mapper.xml中的<select id="selectByPage">
     * @param entity
     * @return
     */
    List<T> selectByPage(T entity) throws AppException ;
    
    /**
     * 针对EaysUI实现的分页查询
     * @param entity
     * @return
     */
    DataGrid<T> datagrid(T entity) throws AppException ;

}
